{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Welly depth units\n",
    "\n",
    "Since v0.4.7: you can decide what `welly` does with the index. But since v0.5.0, the default behaviour has changed. Before, `welly` would convert to metres; now you get whatever is in the file.\n",
    "\n",
    "Thank you to Kent Inverarity for implementing this."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0.4.10.dev42+g3af8468.d20220207'"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import welly\n",
    "\n",
    "welly.__version__"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "~Version Information\r",
      "\r\n",
      " VERS.                 2.0: \r",
      "\r\n",
      " WRAP.                  NO: \r",
      "\r\n",
      " END.                PETRA:GeoPLUS Corporation\r",
      "\r\n",
      "~Well Information Block\r",
      "\r\n",
      "#MNEM.UNIT       Data Type    Information\r",
      "\r\n",
      "#---------    -------------   ---------------------------------\r",
      "\r\n",
      " STRT.F           3128.0000:\r",
      "\r\n",
      " STOP.F           3320.0000:\r",
      "\r\n",
      " STEP.F              0.2500:\r",
      "\r\n"
     ]
    }
   ],
   "source": [
    "!head data/24034.LAS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The default"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3128.0, 'F')"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w = welly.Well.from_las(\"data/24034.LAS\") # The default has changed: you're getting whatever's in the file.\n",
    "\n",
    "gr = w.data['GR']\n",
    "\n",
    "gr.start, gr.index_units"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is the same (this option is obsolete now)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3128.0, 'F')"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w = welly.Well.from_las(\"data/24034.LAS\", index=\"existing\")  # Use what's in the LAS file.\n",
    "\n",
    "gr = w.data['GR']\n",
    "\n",
    "gr.start, gr.index_units"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Converting depth units"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(953.4144000038136, 'm')"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w = welly.Well.from_las(\"data/24034.LAS\", index=\"m\")  # Convert to m.\n",
    "\n",
    "gr = w.data['GR']\n",
    "\n",
    "gr.start, gr.index_units"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3128.0, 'ft')"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w = welly.Well.from_las(\"data/24034.LAS\", index=\"ft\")  # Convert to ft: nothing happens, it's in FT.\n",
    "\n",
    "gr = w.data['GR']\n",
    "\n",
    "gr.start, gr.index_units"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "&copy; 2022 Agile Scientific, CC BY"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "welly",
   "language": "python",
   "name": "welly"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
